<template>
  <div class="log">
    <div class="table_content">
      <el-table :data="logData" style="width: 100%">
        <el-table-column type='index' label="序号" align="center">
        </el-table-column>
        <el-table-column prop="realname" label="访问人真实姓名" align="center">
        </el-table-column>
        <el-table-column prop="method" label="访问方式" align="center"> </el-table-column>
        <el-table-column prop="content" label="访问路径" align="center"> </el-table-column>
        <el-table-column label="访问时间" align="center">
          <template slot-scope="scope">
              {{scope.row.logTime | fmtDate_global}}
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="paginetion">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[2, 4, 6, 8]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { get, post } from "@/utils/request";
export default {
  data() {
    return {
      page:1,
      pageSize:10,
      total:10,
      currentPage:1,
    };
  },
  computed: {},
  methods: {
    async getAllProductData() {
      // 获取参数
      let data = {
        page: this.currentPage,
        pageSize: this.pageSize,
      };
      let res = await get("/baseLog/pageQuery", { ...data });
      // 将data中的产品数组 进行赋值
      this.logData = res.data.list;
      // 页面总数据条数 赋值
      this.total = res.data.total;
    },
    handleSizeChange(val) {
      // 将每页要展示的数据的条数 进行一个更新
      this.pageSize = val;
      // 将当前的页数 重置到第一页
      this.currentPage = 1;
      // 重新调用获取所有产品数据的方法
      this.getAllProductData();
    },
    handleCurrentChange(val) {
      // 将当前页数 与 分页插件动态点击控制的页数相绑定
      this.currentPage = val;
      // 重新调用获取所有产品数据的方法
      this.getAllProductData();
    },
  },
  created() {
    this.getAllProductData()
  },
  mounted() {},
};
</script>
<style scoped>
.paginetion {
  position: fixed;
  bottom: 40px;
  right: 10px;
}
</style>